package com.study.springboot.jpa.entity;

import javax.persistence.*;

@Entity
@SqlResultSetMapping(
        name = "conatctMapping",
        entities = @EntityResult(
                entityClass = Contact.class,
                fields = {
                        @FieldResult(name = "id", column = "id"),
                        @FieldResult(name = "name", column = "name"),
                        @FieldResult(name = "phone", column = "phone"),
                        @FieldResult(name = "mail", column = "mail")})
)
@NamedStoredProcedureQueries({
        @NamedStoredProcedureQuery(
                name = "getContactsLikeName",
                procedureName = "proc_get_contacts_like_name",
                resultClasses = { Contact.class },
                parameters = {
                        @StoredProcedureParameter(
                                mode = ParameterMode.IN,
                                name = "name",
                                type = String.class)
                }
        )
})
public class Contact {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private long id;

    private String name;

    private String phone;

    private String mail;

    public Contact() {
        super();
    }

    public Contact(String name, String phone, String mail) {
        super();

        this.name = name;
        this.phone = phone;
        this.mail = mail;
    }

    public long getId() {
        return this.id;
    }

    public void setId(long value) {
        this.id = value;
    }

    public String getName() {
        return this.name;
    }

    public void setName(String value) {
        this.name = value;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String value) {
        this.phone = value;
    }

    public String getMail() {
        return this.mail;
    }

    public void setMail(String value) {
        this.mail = value;
    }
}
